#ifndef IL_SIMULATOR_H
#define IL_SIMULATOR_H

#include "Common_Types.h"
#include "sys.h"

#define MAX_MESSAGE_SIZE 				1500  //excluding the parameters which is included by CL
#define MQUEUE_REQRT_ID					10010
#define MQUEUE_IL2CLRT_ID				10011
#define MQUEUE_TYPE						100
#define MQUEUE_MAX_MSG_SIZE				1500

#define MAX_NUMBER_OF_COM_REQUESTS 10

#define MAX_FREE_SIZE 10
#define MAX_NEW_SIZE 10


void openMQ();
void* ListenMQ(void*);
U8 selectMsgQ(TimeInternal* timeout);
void testURT();
void testDART();
int REQRT(U8 sequenceNumber);
void testIL2CLRT_DART();
void testIL2CLRT0();
void testIL2CLRT1();
void testIL2CLRT2();
void testIL2CLRT3();


typedef enum
{
	MQUEUE_CL2AP_ind =0,
	MQUEUE_CL2IL_ind,
	MQUEUE_AP2CL_ind,
	MQUEUE_IL2CLREQ_ind,
	MQUEUE_IL2CLRT_ind,
    MQUEUE_COUNT
} MQUEUE_IND_ENUM;

typedef struct
{
	long type;
	U8 msg[MAX_MESSAGE_SIZE];
}MQUEUE_MSG_TYPE;

typedef struct
{
	U8 nodeId;
	U8 ch;
	U8 eT; //in msec
	U8 dT; //in msec
}URT_COMMUNICATION_REQUEST_TYPE;

typedef struct
{
	U8 nodeId;
	U8 ch;
	U8 initialeT;  //in msec
	TimeInternal eT;
	TimeInternal dT;
}URT_COMMUNICATION_REQUEST_PQ_TYPE;
typedef struct
{
	U8 totalNumberOfRequests;
	URT_COMMUNICATION_REQUEST_TYPE comRequests[MAX_NUMBER_OF_COM_REQUESTS];
}URT_MESSAGE_PARAMETER_TYPE;

typedef struct
{
	U8 nodeId;
	U8 ch;
} DEVICE_CHANNEL_TYPE;

typedef struct
{
		U8 requiredSlots;
		DEVICE_CHANNEL_TYPE DeviceChannel;
}NEW_SLOTS_TYPE;  //3 BYTES

typedef struct
{
		DEVICE_CHANNEL_TYPE DeviceChannel;
}FREE_SLOTS_TYPE; //2 BYTES

typedef struct
{
		U8  numberOfNew;
		U8	numberOfFree;
		NEW_SLOTS_TYPE  New[MAX_FREE_SIZE];
		FREE_SLOTS_TYPE Free[MAX_NEW_SIZE];
}DART_MESSAGE_PARAMETER_TYPE;

#endif
